<?php

namespace App\Http\Controllers\admin\defaults;

use App\Helpers\commonFuc;
use App\Models\Admin;


use App\Models\AdminAuthRule;
use App\Models\Config;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
class IndexController extends Controller
{
    private $tpview='admin.defaults.';
    private $thisModel;
    private $thisRequest;

    function __construct(Request $thisRequest)
    {
        $this->thisModel = DB::table('admin_group');
        $this->thisRequest = $thisRequest;
    }



    function index(){

        $loginadmin=session()->get('admin');
        if((int)$loginadmin->group_id!=1){//如果不是超级管理员 都要验证用超级管理员设置的菜单
            $adminmenus=$this->thisModel->find($loginadmin->group_id);
            $adminmenus=AdminAuthRule::getMeun($adminmenus->rules,1);
        }else{
            $adminmenus=AdminAuthRule::getMeun(false,1);
        }
        return view($this->tpview.'index',[
            'adminmenus'=>$adminmenus
            ,'userdata'=>$loginadmin
            ,'logo'=>Config::getValue('LOGO','https://yqsh.oil.wblzf.com/upload/1/common/images/20210723/20210723091438162700287834490.png')
            ,'homeurl'=>'/rqcode'
            ,'indexurl'=>'/'
            ,'search'=>[
                'url'=>'/admin/adminhome',
                'isshow'=>0
            ]
            ,'message'=>[
                'url'=>'/admin/adminindex/home1',
                'isshow'=>0,
                'title'=>'我的消息'
            ]
        ]);



    }
}
